import 'package:flutter/material.dart';
import 'package:flutter_smart_heating/ui/ui.dart';

class UiInput extends StatelessWidget {
  const UiInput({
    super.key,
    this.controller,
    this.focusNode,
    this.placeholder,
    this.maxLength,
    this.keyboardType,
    this.textInputAction,
    this.obscureText = false,
    this.autofocus = false,
    this.keyboardAppearance,
    this.fontSize = 15,
    this.textColor,
    this.onChanged,
    this.onSubmitted,
    this.readOnly = false,
  });
  final TextEditingController? controller;
  final FocusNode? focusNode;
  final String? placeholder;
  final int? maxLength;
  final TextInputType? keyboardType;
  final bool obscureText;
  final bool autofocus;
  final Brightness? keyboardAppearance;
  final double fontSize;
  final Function(String)? onChanged;
  final Function(String)? onSubmitted;
  final TextInputAction? textInputAction;
  final Color? textColor;
  final bool readOnly;
  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: controller,
      focusNode: focusNode,
      maxLength: maxLength,
      keyboardType: keyboardType,
      keyboardAppearance: keyboardAppearance,
      textInputAction: textInputAction,
      autofocus: autofocus,
      style: TextStyle(
        textBaseline: TextBaseline.alphabetic,
        color: textColor,
        height: 1.21,
      ),
      obscureText: obscureText,
      readOnly: readOnly,
      decoration: InputDecoration(
        counterText: '',
        contentPadding: EdgeInsets.zero,
        hintText: placeholder,
        hintStyle: TextStyle(
          color: UiTheme(context).infoColor,
          fontSize: fontSize,
        ),
        filled: false,
        isDense: true,
        border: InputBorder.none,
      ),
      onChanged: onChanged,
      onSubmitted: onSubmitted,
    );
  }
}
